<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>Document</title>
</head>
<body>

<script>

    window.onload=function()
    {
        function createperson(name){

            var localperson=new Object();//创建对象给一变量
            localperson.name=name;//设置属性值name
            return localperson;
         }
        var globalperson=createperson("nick");
        document.write(globalperson.name);
        globalperson=null;//手工解除globalperson的引用
       var arr=[1,3,2,45,6];
            //从小到大排列
            function min_max(value1,value2)
            {
                if(value1<value2)
                {
                    return -1;
                }
                else if(value2<value1){
                    return 1;
                }else{
                return 0;
                }
            }
            //从大到小
             function max_min(value1,value2)
            {
                if(value1>value2)
                {
                    return -1;
                }
                else if(value2>value1){
                    return 1;
                }else{
                return 0;
                }
            }
            arr.sort(max_min);
            alert(arr);
    }
</script>
</body>
</html>